<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans,zh-hk,en,fr-FR,ru,de,ja,id,ko,default">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android,网易云音乐,API," />





  <link rel="alternate" href="http://blog.csdn.net/qq_21265915/rss/list" title="WinterSmileSB101 的个人房间" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/images/myHeadImg.jpeg?v=5.1.0" />






<meta name="description" content="版权声明：本文为 wintersmilesb101 -（个人独立博客– http://wintersmilesb101.online 欢迎访问）博主原创文章，未经博主允许不得转载。源码地址（源码相对于没有那么全，但是道理是一样的）

最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。先说A">
<meta property="og:type" content="article">
<meta property="og:title" content="安卓网易云音乐能用的API">
<meta property="og:url" content="http://WinterSmileSB101.online/2017/03/22/安卓网易云音乐能用的API/index.html">
<meta property="og:site_name" content="WinterSmileSB101 的个人房间">
<meta property="og:description" content="版权声明：本文为 wintersmilesb101 -（个人独立博客– http://wintersmilesb101.online 欢迎访问）博主原创文章，未经博主允许不得转载。源码地址（源码相对于没有那么全，但是道理是一样的）

最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。先说A">
<meta property="og:updated_time" content="2017-03-22T09:03:42.484Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="安卓网易云音乐能用的API">
<meta name="twitter:description" content="版权声明：本文为 wintersmilesb101 -（个人独立博客– http://wintersmilesb101.online 欢迎访问）博主原创文章，未经博主允许不得转载。源码地址（源码相对于没有那么全，但是道理是一样的）

最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。先说A">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"right","display":"post","offset":12,"offset_float":0,"b2t":true,"scrollpercent":true},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6376853978663093000',
      author: 'WinterSmileSB101'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://WinterSmileSB101.online/2017/03/22/安卓网易云音乐能用的API/"/>





  <title> 安卓网易云音乐能用的API | WinterSmileSB101 的个人房间 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">WinterSmileSB101 的个人房间</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">胆小认生，不易相处</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocapitalize="off" autocomplete="off" autocorrect="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://WinterSmileSB101.online/2017/03/22/安卓网易云音乐能用的API/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="WinterSmileSB101">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://on792ofrp.bkt.clouddn.com/17-3-22/29073846-file_1490159480452_d2de.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="WinterSmileSB101 的个人房间">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                安卓网易云音乐能用的API
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-22T16:49:51+08:00">
                2017-03-22
              </time>
            

            
              <span class="post-meta-divider">|</span>
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-check-o"></i>
              </span>
              
                <span class="post-meta-item-text">更新于</span>
              
              <time title="更新于" itemprop="dateModified" datetime="2017-03-22T17:03:42+08:00">
                2017-03-22
              </time>
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index">
                    <span itemprop="name">Android</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/Android-实战/" itemprop="url" rel="index">
                    <span itemprop="name">Android 实战</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/22/安卓网易云音乐能用的API/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/03/22/安卓网易云音乐能用的API/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2017/03/22/安卓网易云音乐能用的API/" class="leancloud_visitors" data-flag-title="安卓网易云音乐能用的API">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数 </span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>版权声明：本文为 wintersmilesb101 -（个人独立博客– <a href="http://wintersmilesb101.online">http://wintersmilesb101.online</a> 欢迎访问）博主原创文章，未经博主允许不得转载。<br><a href="http://download.csdn.net/detail/qq_21265915/9670422" target="_blank" rel="external">源码地址</a>（源码相对于没有那么全，但是道理是一样的）</p>
</blockquote>
<h3 id="最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。"><a href="#最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。" class="headerlink" title="最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。"></a>最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。</h3><h3 id="先说API来源，来自这篇博客：网易云音乐常用API"><a href="#先说API来源，来自这篇博客：网易云音乐常用API" class="headerlink" title="先说API来源，来自这篇博客：网易云音乐常用API"></a>先说API来源，来自这篇博客：<a href="http://moonlib.com/606.html" target="_blank" rel="external">网易云音乐常用API</a></h3><h4 id="我们使用Volley来解析处理网络请求，由于返回的是Json，所以我们使用Gson来解析返回数据。"><a href="#我们使用Volley来解析处理网络请求，由于返回的是Json，所以我们使用Gson来解析返回数据。" class="headerlink" title="我们使用Volley来解析处理网络请求，由于返回的是Json，所以我们使用Gson来解析返回数据。"></a>我们使用Volley来解析处理网络请求，由于返回的是Json，所以我们使用Gson来解析返回数据。</h4><h4 id="实现"><a href="#实现" class="headerlink" title="实现"></a>实现</h4><h4 id="Volley下载以及使用地址：Volley使用指南以及下载"><a href="#Volley下载以及使用地址：Volley使用指南以及下载" class="headerlink" title="Volley下载以及使用地址：Volley使用指南以及下载"></a>Volley下载以及使用地址：<a href="http://www.kwstu.com/ArticleView/kwstu_20144118313429" target="_blank" rel="external">Volley使用指南以及下载</a></h4><h4 id="Gson-jar下载地址：Gson-jar"><a href="#Gson-jar下载地址：Gson-jar" class="headerlink" title="Gson.jar下载地址：Gson.jar"></a>Gson.jar下载地址：<a href="http://download.csdn.net/detail/qq_21265915/9670409" target="_blank" rel="external">Gson.jar</a></h4><h4 id="使用方法："><a href="#使用方法：" class="headerlink" title="使用方法："></a>使用方法：</h4><h4 id="AS中拷贝类库文件到libs文件夹下，然后右键类库文件选择Add-as-Library。"><a href="#AS中拷贝类库文件到libs文件夹下，然后右键类库文件选择Add-as-Library。" class="headerlink" title="AS中拷贝类库文件到libs文件夹下，然后右键类库文件选择Add as Library。"></a>AS中拷贝类库文件到libs文件夹下，然后右键类库文件选择Add as Library。</h4><h4 id="下面附上工具类代码："><a href="#下面附上工具类代码：" class="headerlink" title="下面附上工具类代码："></a>下面附上工具类代码：</h4><h4 id="1-获取RequestQueue实例："><a href="#1-获取RequestQueue实例：" class="headerlink" title="1.获取RequestQueue实例："></a>1.获取RequestQueue实例：</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> winter.zxb.smilesb101.testdemo;  </div><div class="line"><span class="keyword">import</span> android.content.Context;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> com.android.volley.Request;  </div><div class="line"><span class="keyword">import</span> com.android.volley.RequestQueue;  </div><div class="line"><span class="keyword">import</span> com.android.volley.Response;  </div><div class="line"><span class="keyword">import</span> com.android.volley.toolbox.JsonObjectRequest;  </div><div class="line"><span class="keyword">import</span> com.android.volley.toolbox.Volley;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> org.json.JSONObject;  </div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * 网络通信工具类</div><div class="line"> * Created by SmileSB101 on 2016/11/1 0001.</div><div class="line"> */  </div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">InternetUtil</span></span>&#123;  </div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 网络请求队列</div><div class="line">     */  </div><div class="line">    <span class="keyword">private</span> <span class="keyword">static</span> RequestQueue mRequestqueue;  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> RequestQueue <span class="title">getmRequestqueue</span><span class="params">(Context context)</span>  </span></div><div class="line">    &#123;  </div><div class="line">        <span class="keyword">if</span>(mRequestqueue == <span class="keyword">null</span>)  </div><div class="line">        &#123;  </div><div class="line">            mRequestqueue = Volley.newRequestQueue(context);  </div><div class="line">            <span class="keyword">return</span> mRequestqueue;  </div><div class="line">        &#125;  </div><div class="line">        <span class="keyword">else</span>&#123;  </div><div class="line">            <span class="keyword">return</span> mRequestqueue;  </div><div class="line">        &#125;  </div><div class="line">    &#125;  </div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h4 id="2-网络请求处理类"><a href="#2-网络请求处理类" class="headerlink" title="2.网络请求处理类"></a>2.网络请求处理类</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div><div class="line">189</div><div class="line">190</div><div class="line">191</div><div class="line">192</div><div class="line">193</div><div class="line">194</div><div class="line">195</div><div class="line">196</div><div class="line">197</div><div class="line">198</div><div class="line">199</div><div class="line">200</div><div class="line">201</div><div class="line">202</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> winter.zxb.smilesb101.testdemo;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> android.content.Context;  </div><div class="line"><span class="keyword">import</span> android.util.Log;  </div><div class="line"><span class="keyword">import</span> android.util.StateSet;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> com.android.volley.RequestQueue;  </div><div class="line"><span class="keyword">import</span> com.android.volley.Response;  </div><div class="line"><span class="keyword">import</span> com.android.volley.VolleyError;  </div><div class="line"><span class="keyword">import</span> com.android.volley.toolbox.StringRequest;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> org.json.JSONException;  </div><div class="line"><span class="keyword">import</span> org.json.JSONObject;  </div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * 音乐网络类</div><div class="line"> * Created by SmileSB101 on 2016/11/1 0001.</div><div class="line"> */  </div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MusicNetWork</span></span>&#123;  </div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 网易音乐搜索API</div><div class="line">     * http://s.music.163.com/search/get/</div><div class="line">     * 获取方式：GET</div><div class="line">     * 参数：</div><div class="line">     * src: lofter //可为空</div><div class="line">     * type: 1</div><div class="line">     * filterDj: true|false //可为空</div><div class="line">     * s: //关键词</div><div class="line">     * limit: 10 //限制返回结果数</div><div class="line">     * offset: 0 //偏移</div><div class="line">     * callback: //为空时返回json，反之返回jsonp callback</div><div class="line">     * <span class="doctag">@param</span> s</div><div class="line">     * <span class="doctag">@param</span> context</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     * 注意废数字才用‘’符号，要不不能用，否则出错！！</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">SearchMusic</span><span class="params">(Context context,String s,<span class="keyword">int</span> limit,<span class="keyword">int</span> type,<span class="keyword">int</span> offset)</span></span>&#123;  </div><div class="line">        String url = UrlConstants.CLOUD_MUSIC_API_SEARCH + <span class="string">"type="</span>+type+<span class="string">"&amp;s='"</span> + s + <span class="string">"'&amp;limit="</span>+limit+<span class="string">"&amp;offset="</span>+offset;  </div><div class="line">        RequestQueue requestQueue = InternetUtil.getmRequestqueue(context);  </div><div class="line">        StringRequest straingRequest = <span class="keyword">new</span> StringRequest(url,<span class="keyword">new</span> Response.Listener&lt;String&gt;()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onResponse</span><span class="params">(String s)</span></span>&#123;  </div><div class="line">                <span class="keyword">try</span> &#123;  </div><div class="line">                    JSONObject json = <span class="keyword">new</span> JSONObject(s);  </div><div class="line">                    Log.i(<span class="string">"onResponse: "</span>,json.toString());  </div><div class="line">                &#125; <span class="keyword">catch</span>(JSONException e) &#123;  </div><div class="line">                    e.printStackTrace();  </div><div class="line">                &#125;  </div><div class="line">            &#125;  </div><div class="line">        &#125;,<span class="keyword">new</span> Response.ErrorListener()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onErrorResponse</span><span class="params">(VolleyError volleyError)</span></span>&#123;  </div><div class="line">                Log.i(<span class="string">"onResponse: "</span>,volleyError.toString());  </div><div class="line">            &#125;  </div><div class="line">        &#125;);  </div><div class="line">        requestQueue.add(straingRequest);  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 网易云音乐歌曲信息API</div><div class="line">     * <span class="doctag">@param</span> context</div><div class="line">     * <span class="doctag">@param</span> id 歌曲id</div><div class="line">     * <span class="doctag">@param</span> ids 用[]包裹起来的歌曲id 写法%5B %5D</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">Cloud_Music_MusicInfoAPI</span><span class="params">(Context context,String id,String ids)</span>  </span></div><div class="line">    &#123;  </div><div class="line">        String url = UrlConstants.CLOUD_MUSIC_API_MUSICINGO + <span class="string">"id="</span>+id+<span class="string">"&amp;ids=%5B"</span>+ids+<span class="string">"%5D"</span>;  </div><div class="line">        RequestQueue requestQueue = InternetUtil.getmRequestqueue(context);  </div><div class="line">        StringRequest straingRequest = <span class="keyword">new</span> StringRequest(url,<span class="keyword">new</span> Response.Listener&lt;String&gt;()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onResponse</span><span class="params">(String s)</span></span>&#123;  </div><div class="line">                <span class="keyword">try</span> &#123;  </div><div class="line">                    JSONObject json = <span class="keyword">new</span> JSONObject(s);  </div><div class="line">                    Log.i(<span class="string">"onResponse: "</span>,json.toString());  </div><div class="line">                &#125; <span class="keyword">catch</span>(JSONException e) &#123;  </div><div class="line">                    e.printStackTrace();  </div><div class="line">                &#125;  </div><div class="line">            &#125;  </div><div class="line">        &#125;,<span class="keyword">new</span> Response.ErrorListener()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onErrorResponse</span><span class="params">(VolleyError volleyError)</span></span>&#123;  </div><div class="line">                Log.i(<span class="string">"onResponse: "</span>,volleyError.toString());  </div><div class="line">            &#125;  </div><div class="line">        &#125;);  </div><div class="line">        requestQueue.add(straingRequest);  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取歌曲歌词的API</div><div class="line">     *URL：</div><div class="line"></div><div class="line">     GET http://music.163.com/api/song/lyric</div><div class="line"></div><div class="line">     必要参数：</div><div class="line"></div><div class="line">     id：歌曲ID</div><div class="line"></div><div class="line">     lv：值为-1，我猜测应该是判断是否搜索lyric格式</div><div class="line"></div><div class="line">     kv：值为-1，这个值貌似并不影响结果，意义不明</div><div class="line"></div><div class="line">     tv：值为-1，是否搜索tlyric格式</div><div class="line">     * <span class="doctag">@param</span> context</div><div class="line">     * <span class="doctag">@param</span> os</div><div class="line">     * <span class="doctag">@param</span> id</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">Cloud_Muisc_getLrcAPI</span><span class="params">(Context context,String os,String id)</span>  </span></div><div class="line">    &#123;  </div><div class="line">        String url = UrlConstants.CLOUD_MUSIC_API_MUSICLRC + <span class="string">"os="</span>+os+<span class="string">"&amp;id="</span>+id+<span class="string">"&amp;lv=-1&amp;kv=-1&amp;tv=-1"</span>;  </div><div class="line">        RequestQueue requestQueue = InternetUtil.getmRequestqueue(context);  </div><div class="line">        StringRequest straingRequest = <span class="keyword">new</span> StringRequest(url,<span class="keyword">new</span> Response.Listener&lt;String&gt;()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onResponse</span><span class="params">(String s)</span></span>&#123;  </div><div class="line">                <span class="keyword">try</span> &#123;  </div><div class="line">                    JSONObject json = <span class="keyword">new</span> JSONObject(s);  </div><div class="line">                    Log.i(<span class="string">"onResponse: "</span>,json.toString());  </div><div class="line">                &#125; <span class="keyword">catch</span>(JSONException e) &#123;  </div><div class="line">                    e.printStackTrace();  </div><div class="line">                &#125;  </div><div class="line">            &#125;  </div><div class="line">        &#125;,<span class="keyword">new</span> Response.ErrorListener()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onErrorResponse</span><span class="params">(VolleyError volleyError)</span></span>&#123;  </div><div class="line">                Log.i(<span class="string">"onResponse: "</span>,volleyError.toString());  </div><div class="line">            &#125;  </div><div class="line">        &#125;);  </div><div class="line">        requestQueue.add(straingRequest);  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取歌单的API</div><div class="line">     * <span class="doctag">@param</span> context</div><div class="line">     * <span class="doctag">@param</span> id 歌单ID</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">Cloud_Muisc_MusicListSearch</span><span class="params">(Context context,String id)</span>  </span></div><div class="line">    &#123;  </div><div class="line">        String url = UrlConstants.CLOUD_MUSIC_API_MUSICLIST + <span class="string">"id="</span>+id+<span class="string">"&amp;updateTime=-1"</span>;  </div><div class="line">        RequestQueue requestQueue = InternetUtil.getmRequestqueue(context);  </div><div class="line">        StringRequest straingRequest = <span class="keyword">new</span> StringRequest(url,<span class="keyword">new</span> Response.Listener&lt;String&gt;()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onResponse</span><span class="params">(String s)</span></span>&#123;  </div><div class="line">                <span class="keyword">try</span> &#123;  </div><div class="line">                    JSONObject json = <span class="keyword">new</span> JSONObject(s);  </div><div class="line">                    Log.i(<span class="string">"onResponse: "</span>,json.toString());  </div><div class="line">                &#125; <span class="keyword">catch</span>(JSONException e) &#123;  </div><div class="line">                    e.printStackTrace();  </div><div class="line">                &#125;  </div><div class="line">            &#125;  </div><div class="line">        &#125;,<span class="keyword">new</span> Response.ErrorListener()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onErrorResponse</span><span class="params">(VolleyError volleyError)</span></span>&#123;  </div><div class="line">                Log.i(<span class="string">"onResponse: "</span>,volleyError.toString());  </div><div class="line">            &#125;  </div><div class="line">        &#125;);  </div><div class="line">        requestQueue.add(straingRequest);  </div><div class="line">    &#125;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">static</span> JSONObject json = <span class="keyword">null</span>;  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> JSONObject <span class="title">getInfoFromUrl_Volley</span><span class="params">(String url,Context context)</span>  </span></div><div class="line">    &#123;  </div><div class="line">        json = <span class="keyword">null</span>;  </div><div class="line">        RequestQueue requestQueue = InternetUtil.getmRequestqueue(context);  </div><div class="line">        StringRequest straingRequest = <span class="keyword">new</span> StringRequest(url,<span class="keyword">new</span> Response.Listener&lt;String&gt;()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onResponse</span><span class="params">(String s)</span></span>&#123;  </div><div class="line">                <span class="keyword">try</span> &#123;  </div><div class="line">                    json = <span class="keyword">new</span> JSONObject(s);  </div><div class="line">                    Log.i(<span class="string">"onResponse: "</span>,json.toString());  </div><div class="line">                &#125; <span class="keyword">catch</span>(JSONException e) &#123;  </div><div class="line">                    e.printStackTrace();  </div><div class="line">                &#125;  </div><div class="line">            &#125;  </div><div class="line">        &#125;,<span class="keyword">new</span> Response.ErrorListener()&#123;  </div><div class="line">            <span class="meta">@Override</span>  </div><div class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onErrorResponse</span><span class="params">(VolleyError volleyError)</span></span>&#123;  </div><div class="line">                Log.i(<span class="string">"onResponse: "</span>,volleyError.toString());  </div><div class="line">            &#125;  </div><div class="line">        &#125;);  </div><div class="line">        requestQueue.add(straingRequest);  </div><div class="line">        <span class="keyword">return</span> json;  </div><div class="line">    &#125;  </div><div class="line">    <span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UrlConstants</span> </span>&#123;  </div><div class="line">        <span class="comment">/**</span></div><div class="line">         * 云音乐搜索API网址</div><div class="line">         */  </div><div class="line">        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> String CLOUD_MUSIC_API_SEARCH = <span class="string">"http://s.music.163.com/search/get/?"</span>;  </div><div class="line">        <span class="comment">/**</span></div><div class="line">         * 歌曲信息API网址</div><div class="line">         */  </div><div class="line">        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> String CLOUD_MUSIC_API_MUSICINGO = <span class="string">"http://music.163.com/api/song/detail/?"</span>;  </div><div class="line">        <span class="comment">/**</span></div><div class="line">         * 获取歌曲的歌词</div><div class="line">         */  </div><div class="line">        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> String CLOUD_MUSIC_API_MUSICLRC = <span class="string">"http://music.163.com/api/song/lyric?"</span>;  </div><div class="line">        <span class="comment">/**</span></div><div class="line">         * 获取歌单</div><div class="line">         */  </div><div class="line">        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> String CLOUD_MUSIC_API_MUSICLIST = <span class="string">"http://music.163.com/api/playlist/detail?"</span>;  </div><div class="line">    &#125;  </div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h4 id="调用类："><a href="#调用类：" class="headerlink" title="调用类："></a>调用类：</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> winter.zxb.smilesb101.testdemo;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> android.support.v7.app.AppCompatActivity;  </div><div class="line"><span class="keyword">import</span> android.os.Bundle;  </div><div class="line"><span class="keyword">import</span> android.util.Log;  </div><div class="line"><span class="keyword">import</span> android.view.View;  </div><div class="line"><span class="keyword">import</span> android.widget.Button;  </div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MainActivity</span> <span class="keyword">extends</span> <span class="title">AppCompatActivity</span> <span class="keyword">implements</span> <span class="title">View</span>.<span class="title">OnClickListener</span></span>&#123;  </div><div class="line"></div><div class="line">    <span class="keyword">private</span> Button NetWorkTest;  </div><div class="line">    <span class="meta">@Override</span>  </div><div class="line">    <span class="function"><span class="keyword">protected</span> <span class="keyword">void</span> <span class="title">onCreate</span><span class="params">(Bundle savedInstanceState)</span></span>&#123;  </div><div class="line">        <span class="keyword">super</span>.onCreate(savedInstanceState);  </div><div class="line">        setContentView(R.layout.activity_main);  </div><div class="line">        NetWorkTest = (Button)findViewById(R.id.NetWorkTest);  </div><div class="line">        NetWorkTest.setOnClickListener(<span class="keyword">this</span>);  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="meta">@Override</span>  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onClick</span><span class="params">(View v)</span></span>&#123;  </div><div class="line">        <span class="keyword">switch</span>(v.getId())  </div><div class="line">        &#123;  </div><div class="line">            <span class="keyword">case</span> R.id.NetWorkTest:<span class="comment">//网络测试  </span></div><div class="line">                Log.i(<span class="string">"进入"</span>,<span class="string">"onClick: "</span>);  </div><div class="line">                <span class="comment">//MusicNetWork.SearchMusic(this,"光荣",10,1,0);  </span></div><div class="line">                <span class="comment">//MusicNetWork.Cloud_Music_MusicInfoAPI(this,"26562231","26562231");  </span></div><div class="line">                <span class="comment">//MusicNetWork.Cloud_Muisc_getLrcAPI(this,"pc","26562231");  </span></div><div class="line">                MusicNetWork.Cloud_Muisc_MusicListSearch(<span class="keyword">this</span>,<span class="string">"37880978"</span>);  </div><div class="line">                <span class="keyword">break</span>;  </div><div class="line">        &#125;  </div><div class="line">    &#125;  </div><div class="line">&#125;</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        
<div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="http://on792ofrp.bkt.clouddn.com/17-3-22/89969433-file_1490159480281_107f8.jpg" alt="WinterSmileSB101 wechat" style="width: 200px; max-width: 100%;"/>
    <div>欢迎关注我的微信公众帐号，不定期推送各种技术文章</div>
</div>


      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <ul class="post-copyright">
    <li class="post-copyright-author">
      <strong>本文作者：</strong>
      WinterSmileSB101
    </li>
    <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://WinterSmileSB101.online/2017/03/22/安卓网易云音乐能用的API/" title="安卓网易云音乐能用的API">http://WinterSmileSB101.online/2017/03/22/安卓网易云音乐能用的API/</a>
    </li>
    <li class="post-copyright-license">
      <strong>版权声明： </strong>
      本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
    </li>
  </ul>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag"># Android</a>
          
            <a href="/tags/网易云音乐/" rel="tag"># 网易云音乐</a>
          
            <a href="/tags/API/" rel="tag"># API</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/03/22/安卓中字符串分割（Split）的坑/" rel="next" title="安卓中字符串分割（Split）的坑">
                <i class="fa fa-chevron-left"></i> 安卓中字符串分割（Split）的坑
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/03/22/Android实践-自定义dialog从屏幕底部弹出并且充满屏幕宽度/" rel="prev" title="Android实践-自定义dialog从屏幕底部弹出并且充满屏幕宽度">
                Android实践-自定义dialog从屏幕底部弹出并且充满屏幕宽度 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2017/03/22/安卓网易云音乐能用的API/"
     data-title="安卓网易云音乐能用的API"
     data-content=""
     data-url="http://WinterSmileSB101.online/2017/03/22/安卓网易云音乐能用的API/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2017/03/22/安卓网易云音乐能用的API/"
           data-title="安卓网易云音乐能用的API" data-url="http://WinterSmileSB101.online/2017/03/22/安卓网易云音乐能用的API/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://on792ofrp.bkt.clouddn.com/17-3-22/29073846-file_1490159480452_d2de.jpg"
               alt="WinterSmileSB101" />
          <p class="site-author-name" itemprop="name">WinterSmileSB101</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
           
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">52</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">26</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">113</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="http://blog.csdn.net/qq_21265915/rss/list" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <!--自己写的社交链接-->
        <div class="links-of-author motion-element">
         <span class="links-of-author-item">
         <a href="https://github.com/WinterSmileSB101" title="Github">
         <i class="fa fa-fw fa-github fa-lg"></i>
         </a>
         </span>
         <span class="links-of-author-item">
                  <a href="http://weibo.com/5602632941/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1" title="微博">
                  <i class="fa fa-fw fa-weibo fa-lg"></i>
                  </a>
                  </span>
         <span class="links-of-author-item">
         <a href="http://www.jianshu.com/users/73344bc7e890/timeline" title="简书">
         <i class="fa fa-fw fa-bookmark fa-lg"></i>
         </a>
         </span>
<br />
        <span class="links-of-author-item">
                 <a href="https://www.douban.com/people/159359470/" title="豆瓣">
                 <i class="fa fa-fw fa-newspaper-o fa-lg"></i>
                 </a>
                 </span>
        <span class="links-of-author-item">
                 <a href="http://blog.csdn.net/qq_21265915" title="CSDN博客">
                 <i class="fa fa-fw fa-bug fa-lg"></i>
                 </a>
                 </span>
        </div>
        <!--自己写的社交链接-->

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。"><span class="nav-number">1.</span> <span class="nav-text">最近在做一个仿网易云音乐的APP，需要通过网络获取歌曲以及歌词，于是做了这些API整合，这里面的都是我测试过能够获取到信息的API，写这篇博客为了备份与分享。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#先说API来源，来自这篇博客：网易云音乐常用API"><span class="nav-number">2.</span> <span class="nav-text">先说API来源，来自这篇博客：网易云音乐常用API</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#我们使用Volley来解析处理网络请求，由于返回的是Json，所以我们使用Gson来解析返回数据。"><span class="nav-number">2.1.</span> <span class="nav-text">我们使用Volley来解析处理网络请求，由于返回的是Json，所以我们使用Gson来解析返回数据。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实现"><span class="nav-number">2.2.</span> <span class="nav-text">实现</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Volley下载以及使用地址：Volley使用指南以及下载"><span class="nav-number">2.3.</span> <span class="nav-text">Volley下载以及使用地址：Volley使用指南以及下载</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Gson-jar下载地址：Gson-jar"><span class="nav-number">2.4.</span> <span class="nav-text">Gson.jar下载地址：Gson.jar</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#使用方法："><span class="nav-number">2.5.</span> <span class="nav-text">使用方法：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#AS中拷贝类库文件到libs文件夹下，然后右键类库文件选择Add-as-Library。"><span class="nav-number">2.6.</span> <span class="nav-text">AS中拷贝类库文件到libs文件夹下，然后右键类库文件选择Add as Library。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#下面附上工具类代码："><span class="nav-number">2.7.</span> <span class="nav-text">下面附上工具类代码：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-获取RequestQueue实例："><span class="nav-number">2.8.</span> <span class="nav-text">1.获取RequestQueue实例：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-网络请求处理类"><span class="nav-number">2.9.</span> <span class="nav-text">2.网络请求处理类</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#调用类："><span class="nav-number">2.10.</span> <span class="nav-text">调用类：</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2017.3.20 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Powered By - WinterSmileSB101</span>
</div>


<div class="powered-by">
    个人专属
</div>

<div class="theme-info">
  博客 -
  WinterSmileSB101
</div>


        

        
      </div>
    </footer>

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"wintersmilesb101"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
      <script src="/js/src/hook-duoshuo.js?v=5.1.0"></script>
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  
















  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("cOFi0858xVYxKW1wnErxqEra-gzGzoHsz", "7LaqqR82XnjzTbkv5eCKw5aW");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  

</body>
</html>
